#pragma once

namespace luabind
{
	template <>
	struct default_converter<std::string>
		: native_converter_base<std::string>
	{
		static int compute_score(lua_State* L, int index)
		{
			int type = lua_type(L, index);

			return type == LUA_TSTRING||type==LUA_TNUMBER? 0 : -1;
		}

		std::string from(lua_State* L, int index)
		{	
			switch(lua_type(L, index))
			{
			case LUA_TSTRING:
				return lua_tostring(L, index);
				break;
			case LUA_TNUMBER:
				return Pattern::Utility::ToString(lua_tonumber(l,index));
				break;
			}

			return ret;
		}

		void to(lua_State* L, std::string const& x)
		{			
			lua_pushstring(L, x.c_str());
		}
	};

	template <>
	struct default_converter<std::string const&>
		: default_converter<std::string>
	{};
}
